﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
            {
                Path = "~/scripts/jquery-3.5.1.min.js",
                DebugPath = "~/scripts/jquery-3.5.1.js",
                CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-3.5.1.min.js",
                CdnDebugPath =
                "http://ajax.microsoft.com/ajax/jQuery/jquery-3.5.1.js"
            });
            this.RangeValidator2.MaximumValue = DateTime.Now.ToShortDateString();
        }

        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value == "admin")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (fud.HasFile == true)
            {
                string fn = fud.FileName;
                if (fn.EndsWith(".jpg") || fn.EndsWith(".gif") || fn.EndsWith(".png"))
                {
                    string url = Server.MapPath(@"~\img\" + fn);
                    fud.SaveAs(url);
                    Image1.ImageUrl = @"~\img\" + fn;
                }
                else
                {
                    Literal2.Text = "文件格式不正确。";
                }
            }
            else
            {
                Literal2.Text = "上传文件不能为空！";
            }
            if (Page.IsValid)
            {
                Literal1.Text = "注册成功！ <a href='/WebForm4.aspx'>点击跳转到登录页面</a>";
            }
        }

    }
}